﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TurnamentOrganizer
{
    public partial class AddPlayersForm : Form
    {
        Tournament main;

        public AddPlayersForm(Tournament main)
        {
            InitializeComponent();
            this.main = main;
            comboBoxLocation.DataSource = main.Locations;
        }        

        private void buttonAddPlayer_Click(object sender, EventArgs e)
        {
            if (this.textBoxName.Text != "" && this.comboBoxLocation.Text != "")
            {
                var newPlayer = new Player(this.textBoxName.Text) {HomeLocation = this.comboBoxLocation.Text};

                switch (this.comboBoxPaid.Text)
                {
                    case "Ja":
                        newPlayer.HasPaid = true;
                        break;
                    case "Nej":
                        newPlayer.HasPaid = false;
                        break;
                    default:
                        newPlayer.HasPaid = false;
                        break;
                }

                if (this.comboBoxPaid.Text == "Ja")
                {
                    
                }

                main.playerList.Add(newPlayer);
                

                this.Close();
            }
            else
            {
                MessageBox.Show(@"Du mangler at indtaste oplysninger");
            }
        }        
    }
}
